<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Windows Media Player控制播放器</title>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="table1">
	<tr>
		<td colspan="2" align="center">
			<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer" width="400" height="300">
				<param name="URL" value>
				<param name="rate" value="1">
				<param name="balance" value="0">
				<param name="currentPosition" value="0">
				<param name="defaultFrame" value>
				<param name="playCount" value="">
				<param name="autoStart" value="0">
				<param name="currentMarker" value="0">
				<param name="invokeURLs" value="0">
				<param name="baseURL" value>
				<param name="volume" value="100">
				<param name="mute" value="-1">
				<param name="uiMode" value="none">
				<param name="stretchToFit" value="0">
				<param name="windowlessVideo" value="0">
				<param name="enabled" value="-1">
				<param name="enableContextMenu" value="-1">
				<param name="fullScreen" value="0">
				<param name="SAMIStyle" value>
				<param name="SAMILang" value>
				<param name="SAMIFilename" value>
				<param name="captioningID" value>
				<param name="enableErrorDialogs" value="0">
			</object>
		</td>
	</tr>
	<tr><td height="20" colspan="2" align="center"><font color=red><span id="playerinfo3"></span></font></td></tr>
	<tr>
		<td width="60%" height="20"><input type="file" id="FileBtn" style="visibility:hidden">
		<span id="playerinfo1"></span><font color=blue><span id="playerinfo2"></span></font></td>
		<td width="40%" height="20"><span id="playerinfo"></span></td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<input type="button" name="openfile" title="打开文件" onclick="openfile()" value="打开文件">
			<input type="button" name="play" title="播放" onclick="play();" value="播放">
			<input type="button" name="pause" title="暂停" onclick="pause();" value="暂停">
			<input type="button" name="stop" title="停止" onclick="stop();" value="停止">
			<input type="button" name="voldown" title="音量-" onclick="voldown();" value="音量-">
			<input type="button" name="volup" title="音量+" onclick="volup();" value="音量+">
			<input type="button" name="mute" title="静音?" onclick="mute();" value="静音?">
			<input type="button" name="balance" title="声道" onclick="balance();" value="声道">
			<input type="button" title="刷新" onclick="location.reload();" value="刷新">
			<input type="button" title="全屏" value="全屏" onclick="fullScreen();">
		</td>
	</tr>
</table>
<script language="javascript">
var state;
var varb;
var varfullscreen=0;

function loop()
{
	WindowsMediaPlayer.playCount=2;
}

function openfile()
{
	var fstr='';
	FileBtn.click();
	if (FileBtn.value=='')
	return;
	WindowsMediaPlayer.URL=FileBtn.value;
	playerinfo1.innerHTML = '全声道 ';
	playerinfo3.innerHTML="<b><font color=green>当前播放文件的路径和名称是: </font></b>"+FileBtn.value;
}

function playerinit()
{
	WindowsMediaPlayer.url="unit10.wmv";             //定义你自己的文件
	WindowsMediaPlayer.settings.autoStart = false ;
}

function play()
{
	//if(WindowsMediaPlayer.URL='')alert('请打开文件');return; onload="playerinit()"
	if (WindowsMediaPlayer.controls.isavailable('play'))
	{
		WindowsMediaPlayer.controls.play();
		state=setInterval("updatetime()",1000);
		playerinfo.innerHTML = "播放"
		varfullscreen=1;
		playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume;
	}
}

function voldown()
{
	if ( WindowsMediaPlayer.settings.volume < 5 )
	{
		WindowsMediaPlayer.settings.volume = 0;
		playerinfo2.innerHTML = "音量:0";
		playerinfo1.innerHTML = '沉默中 ';
	}
	else
	{
		WindowsMediaPlayer.settings.volume -= 5;
		playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume;
		playerinfo1.innerHTML = '非静音 ';
	}
}

function volup()
{
	if ( WindowsMediaPlayer.settings.volume > 95 )
	{
		WindowsMediaPlayer.settings.volume = 100;
		playerinfo2.innerHTML = "音量:100";
		playerinfo1.innerHTML = '最大音 ';
	}
	else
	{
		WindowsMediaPlayer.settings.volume += 5;
		playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume;
		playerinfo1.innerHTML = '非静音 ';
	}
}

function pause()
{
	if (WindowsMediaPlayer.controls.isavailable('pause'))
	{
		WindowsMediaPlayer.controls.pause();
		clearInterval(state);
		playerinfo.innerHTML = "暂停";
		varfullscreen=1;
	}
}

function stop()
{
	if (WindowsMediaPlayer.controls.isavailable('stop'))
	{
		WindowsMediaPlayer.controls.stop();
		clearInterval(state);
		playerinfo.innerHTML = "停止"
		varfullscreen=0;
	}
}

function mute()
{
	WindowsMediaPlayer.settings.mute = !WindowsMediaPlayer.settings.mute;
	if(varb!=1)
	{
		playerinfo1.innerHTML = '静音中 ';
		document.all.volup.disabled=true;
		document.all.voldown.disabled=true;
		document.all.balance.disabled=true;
		varb=1;
	}
	else
	{
		playerinfo1.innerHTML = '非静音 ';
		document.all.volup.disabled=false;
		document.all.voldown.disabled=false;
		document.all.balance.disabled=false;
		varb=0;
	}
}

function balance()
{
	switch (WindowsMediaPlayer.settings.balance)
	{
	case 0:
		WindowsMediaPlayer.settings.balance = 100;
		playerinfo1.innerHTML = '左声道 ';
		break;
	case 100:
		WindowsMediaPlayer.settings.balance = -100;
		playerinfo1.innerHTML = '右声道 ';
		break;
	case -100:
		WindowsMediaPlayer.settings.balance = 0;
		playerinfo1.innerHTML = '全声道 ';
		break;
	default :
		WindowsMediaPlayer.settings.balance = 0;
		playerinfo1.innerHTML = '全声道 ';
		break;
	}
}

function fullScreen()
{
	if (varfullscreen) {
		WindowsMediaPlayer.fullScreen='true';
	}
	else {
		WindowsMediaPlayer.fullScreen='0';
	}
}


function updatetime()
{
	if(WindowsMediaPlayer.controls.currentPositionString=='') {
		playerinfo.innerHTML = "00:00" + " / " + WindowsMediaPlayer.currentMedia.durationString;
		varfullscreen=0;
	}
	else {
		playerinfo.innerHTML = WindowsMediaPlayer.controls.currentPositionString + " / " + WindowsMediaPlayer.currentMedia.durationString;
	}
}
</script>
<script language = "JavaScript" for=WindowsMediaPlayer event=playstatechange(newstate)>
switch (newstate)
{
	case 1:
		playerinfo.innerHTML = "停止";
		break;
	case 2:
		playerinfo.innerHTML = "暂停";
		break;
	case 3:
		playerinfo.innerHTML = "正在播放";
		break;
	case 4:
		playerinfo.innerHTML = "4";
		break;
	case 5:
		playerinfo.innerHTML = "5";
		break;
	case 6:
		playerinfo.innerHTML = "正在缓冲...";
		break;
	case 7:
		playerinfo.innerHTML = "7";
		break;
	case 8:
		playerinfo.innerHTML = "8";
		break;
	case 9:
		playerinfo.innerHTML = "正在连接...";
		break;
	case 10:
		playerinfo.innerHTML = "准备就绪";
		break;
	case 11:
		playerinfo.innerHTML = "11";
		break;
	default:
		playerinfo.innerHTML = "";
}
</script>
</body>
</html>